package c2.advanced;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.context.ApplicationContext;

@Slf4j
public class C2Advanced {

    public static final String version() {
        return "C2Advanced 2023-07-17 14:57";
    }

    public static ApplicationContext ctx;

    /**
     * 退出
     */
    public static void shutdown(String message) {
        log.info("尝试执行shutdown, 因为 {}", message);
        if (ctx == null) {
            log.error("C2Advanced.ctx==null shutdown拒绝执行");
            return;
        }
        int exitCode = SpringApplication.exit(ctx);
        System.exit(exitCode);
    }
}
